// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>
#include <iostream>
#include <vcclr.h>
//#include "TApplication.h"

using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;

#pragma managed

void ManagedStringFunc(char* s) {
   String^ ms = Marshal::PtrToStringAnsi((IntPtr)s);
   Console::WriteLine("(managed) received '{0}'", ms);
}

#pragma unmanaged

void NativeProvidesAString() {
   cout << "(unmanaged) calling managed func...\n";
   char* s = "test string";
   ManagedStringFunc(s);
}

string GetFileName(string filepath)
{
	return filepath.substr(filepath.find_last_of("/\\"));
}

//#pragma managed

int main(int argc, char* argv[])
{
	int numberOfFiles = argc-1;
	string* filepaths = new string[numberOfFiles];
	if (argc > 1)
	{
		for (int i=0;i<numberOfFiles;i++)
		{
			filepaths[i] = argv[i+1];
			cout << GetFileName(filepaths[i]) << endl;
		}
	}
	NativeProvidesAString();
}
